from random import randrange
from Tkinter import *

'''``````````````````````````````````````````````````````````````````````````````````````````````````````````````
` Class responsible for creating buildings and determining whether beings have collided with the given instance `
``````````````````````````````````````````````````````````````````````````````````````````````````````````````'''

class Building:
	def __init__(self, canvas):
		self.canvas = canvas
		
		#assign the width and height of this building
		self.width = randrange(10,100)
		self.height = randrange(10,100)
		
		#then randomly choose this building's location
		self.x1 = randrange(0,600)
		self.x2 = self.x1+self.width
		
		self.y1 = randrange(0,400)
		self.y2 = self.y1+self.height
		
		#draw the rectangle
		self.rectangle = canvas.create_rectangle([[self.x1, self.y1],[self.x2, self.y2]], fill="#333", outline="#333")
	def hit_test(self,x,y):
		if x >= self.x1 and x <= self.x2 and y >= self.y1 and y <= self.y2:
			#if the point is within the area of this building's rectangle, then return true
			return True
			
		else:
			#else, return false
			return False